
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  
  <title>MongoDB | cymiao</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="安装 DOClever 需要安装 MongoDB作为数据库,这里就学习安装下MongoDB. 下载软件官网下载合适的版本MongoDB下载 windows下安装MongoDB 安装MongoDB       然后直接下一步安装即可.  注意: 安装时可能会出现报错:服务启动失败,这时候选择ignore;  配置环境变量 把安装目录,例如这里我安装的是:D:\MongoDB\bin添加到环境变量中">
<meta name="keywords" content="MongoDB">
<meta property="og:type" content="article">
<meta property="og:title" content="MongoDB">
<meta property="og:url" content="https://cyshigehaohaizi.gitee.io/2018/07/31/MongoDB/MongoDB/index.html">
<meta property="og:site_name" content="cymiao">
<meta property="og:description" content="安装 DOClever 需要安装 MongoDB作为数据库,这里就学习安装下MongoDB. 下载软件官网下载合适的版本MongoDB下载 windows下安装MongoDB 安装MongoDB       然后直接下一步安装即可.  注意: 安装时可能会出现报错:服务启动失败,这时候选择ignore;  配置环境变量 把安装目录,例如这里我安装的是:D:\MongoDB\bin添加到环境变量中">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/1.png">
<meta property="og:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/2.png">
<meta property="og:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/3.png">
<meta property="og:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/4.png">
<meta property="og:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/5.png">
<meta property="og:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/6.png">
<meta property="og:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/7.png">
<meta property="og:updated_time" content="2018-08-03T06:51:37.785Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="MongoDB">
<meta name="twitter:description" content="安装 DOClever 需要安装 MongoDB作为数据库,这里就学习安装下MongoDB. 下载软件官网下载合适的版本MongoDB下载 windows下安装MongoDB 安装MongoDB       然后直接下一步安装即可.  注意: 安装时可能会出现报错:服务启动失败,这时候选择ignore;  配置环境变量 把安装目录,例如这里我安装的是:D:\MongoDB\bin添加到环境变量中">
<meta name="twitter:image" content="https://cyshigehaohaizi.gitee.io/cy_home/2018/07/31/MongoDB/MongoDB/1.png">
  
    <link rel="alternative" href="/atom.xml" title="cymiao" type="application/atom+xml">
  
  
  <link rel="stylesheet" href="/cy_home/css/style.css">
  
    <!--<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">-->
  
  <!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7/html5shiv.min.js"></script><![endif]-->
  
  

</head>

<body>
<div id="container">
  <div id="wrap">
    <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <nav id="upper-nav" class="inner">
      <a id="main-nav-toggle" class="nav-icon"></a>
      <div class="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        
          <a id="nav-github" class="nav-icon" href="https://github.com/myname"></a>
        
      </div>
    </nav>
    <div id="header-title">
      
        <h1 id="blog-title-wrap">
          <a href="/" id="blog-title">My Blog</a>
        </h1>
      
    </div>
    <div id="contenedor">
      <ul class="cube">
        <li class="cara">cy</li>
        <li class="cara">A</li>
        <li class="cara">B</li>
        <li class="cara">C</li>
        <li class="cara">D</li>
        <li class="cara">E</li>
      </ul>
    </div>
    <nav id="main-nav">
      
        <a class="main-nav-link" href="/cy_home/">Home</a>
      
        <a class="main-nav-link" href="/cy_home/archives">Archives</a>
      
        <a class="main-nav-link" href="/cy_home/about">About</a>
      
      <a class="main-nav-link st-search-show-outputs">搜索</a>
    </nav>
  </div>
</header>

    <div class="outer">
      <section id="main"><article id="post-MongoDB/MongoDB" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <h3 href="/cy_home/2018/07/31/MongoDB/MongoDB/" class="article-date">
  <time datetime="2018-07-31T06:48:09.000Z" itemprop="datePublished">2018-07-31</time>
</h3>
    
  </div>
  <div class="article-inner">
  <div class="curve-down">
  <div class="fill-content">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      MongoDB
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        
        <p>安装 DOClever 需要安装 MongoDB作为数据库,这里就学习安装下MongoDB.</p>
<h4 id="下载软件"><a href="#下载软件" class="headerlink" title="下载软件"></a>下载软件</h4><p>官网下载合适的版本<a href="https://www.mongodb.com/dr/fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.0-signed.msi/download" title="MongoDB下载" target="_blank" rel="noopener">MongoDB下载</a></p>
<h4 id="windows下安装MongoDB"><a href="#windows下安装MongoDB" class="headerlink" title="windows下安装MongoDB"></a>windows下安装MongoDB</h4><ul>
<li><p>安装MongoDB</p>
<p><img src="/cy_home/2018/07/31/MongoDB/MongoDB/1.png" alt="图片介绍"></p>
</li>
</ul>
<p> <img src="/cy_home/2018/07/31/MongoDB/MongoDB/2.png" alt="图片介绍"></p>
<p> 然后直接下一步安装即可.</p>
<p> <strong>注意:</strong> 安装时可能会出现报错:服务启动失败,这时候选择ignore;</p>
<ul>
<li>配置环境变量<ul>
<li>把安装目录,例如这里我安装的是:<code>D:\MongoDB\bin</code>添加到环境变量中</li>
</ul>
</li>
</ul>
<ul>
<li><p>配置本地服务</p>
<p>因为我们这里使用的是社区免费版本的,所以可能默认安装的MongoDB服务启动不起来,所以我们先删除默认的MongoDB服务</p>
<figure class="highlight dockerfile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#删除默认的MongoDB服务</span></span><br><span class="line"></span><br><span class="line">管理员运行的<span class="keyword">cmd</span><span class="bash">&gt;sc delete MongoDB </span></span><br><span class="line"><span class="bash"></span></span><br><span class="line"><span class="bash"><span class="comment">#然后添加自定义service:</span></span></span><br><span class="line"><span class="bash"></span></span><br><span class="line"><span class="bash">管理员运行的cmd&gt; mongod.exe --dbpath <span class="string">"D:\MongoDB\data"</span> --logpath <span class="string">"D:\MongoDB\log\db.log"</span> --install --serviceName <span class="string">"MongoDB"</span></span></span><br></pre></td></tr></table></figure>
<p><strong>注意:</strong>有可能会创建不成功,所以可以先创建对应的data,以及log\db.log文档到对应的文档.</p>
</li>
<li><p>运行测试</p>
<ul>
<li>运行服务 <code>net start MongoDB</code></li>
<li><p>测试:访问 <a href="http://localhost:27017/" title="http://localhost:27017/" target="_blank" rel="noopener">http://localhost:27017/</a></p>
<p><img src="/cy_home/2018/07/31/MongoDB/MongoDB/3.png" alt="图片介绍"></p>
</li>
</ul>
</li>
</ul>
<p>安装完成</p>
<h4 id="连接测试"><a href="#连接测试" class="headerlink" title="连接测试"></a>连接测试</h4><ol>
<li><p>打开<code>MongoDB compass</code> (同MongoDB一同安装的),直接点击连接</p>
<p><img src="/cy_home/2018/07/31/MongoDB/MongoDB/4.png" alt="图片介绍"></p>
</li>
<li><p>连接成功之后创建一个数据库</p>
<p><img src="/cy_home/2018/07/31/MongoDB/MongoDB/5.png" alt="图片介绍"></p>
<p><img src="/cy_home/2018/07/31/MongoDB/MongoDB/6.png" alt="图片介绍"></p>
<p><img src="/cy_home/2018/07/31/MongoDB/MongoDB/7.png" alt="图片介绍"></p>
</li>
</ol>
<p>如此一个简单MongoDB数据库就创建完成了</p>

      
    </div>
    <footer class="article-footer">
      <div class="article-footer-content">
        
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/cy_home/tags/MongoDB/">MongoDB</a></li></ul>

        <a data-url="https://cyshigehaohaizi.gitee.io/2018/07/31/MongoDB/MongoDB/" data-id="cjnr90az30002ok76rg0dqp1w" class="article-share-link">分享到</a>
        
      </div>
    </footer>
  </div>
  </div>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/cy_home/2018/08/02/doclever/doclever_use/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">下一篇</strong>
      <div class="article-nav-title">
        
          doclever使用
        
      </div>
    </a>
  
  
    <a href="/cy_home/2018/07/31/doclever/doclever/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">上一篇</strong>
      <div class="article-nav-title">DOClever window下安装</div>
    </a>
  
</nav>

  
</article>


</section>
      
      <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">近期文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/cy_home/2018/10/27/npm/npm组件发布/">npm + webpack + vue 创建发布一个组件</a>
          </li>
        
          <li>
            <a href="/cy_home/2018/10/27/npm/">npm</a>
          </li>
        
          <li>
            <a href="/cy_home/2018/08/07/node/node使用记录/">node使用记录</a>
          </li>
        
          <li>
            <a href="/cy_home/2018/08/02/doclever/doclever_use/">doclever使用</a>
          </li>
        
          <li>
            <a href="/cy_home/2018/07/31/MongoDB/MongoDB/">MongoDB</a>
          </li>
        
      </ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/DOClever/">DOClever</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/MongoDB/">MongoDB</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/doclever/">doclever</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/mock/">mock</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/node/">node</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/npm/">npm</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/rap/">rap</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/taFaceNex/">taFaceNex</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/vue/">vue</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/vue-cli/">vue-cli</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/cy_home/tags/webpack/">webpack</a><span class="tag-list-count">1</span></li></ul>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/cy_home/archives/2018/10/">十月 2018</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/cy_home/archives/2018/08/">八月 2018</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/cy_home/archives/2018/07/">七月 2018</a><span class="archive-list-count">5</span></li></ul>
    </div>
  </div>

  
</aside>
      
    </div>
    <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 cy<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
      .
      Theme by <a href="https://github.com/sun11/hexo-theme-paperbox" target="_blank">Paperbox</a>
    </div>
  </div>
</footer>
  </div>
  <nav id="mobile-nav">
  
    <a href="/cy_home/" class="mobile-nav-link">Home</a>
  
    <a href="/cy_home/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/cy_home/about" class="mobile-nav-link">About</a>
  
  <a href="#search" class="mobile-nav-link st-search-show-outputs">搜索</a>
</nav>

  

<!-- totop start -->
<div id="totop">
	<a title="返回顶部"></a>
</div>
<!-- totop end -->

<!-- swiftype search start -->

<!-- swiftype search end -->



<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/lrsjng.jquery-qrcode/0.12.0/jquery.qrcode.min.js"></script>


  <link rel="stylesheet" href="/cy_home/fancybox/jquery.fancybox.css">
  <script src="/cy_home/fancybox/jquery.fancybox.pack.js"></script>


<script src="/cy_home/js/script.js"></script>

</div>
</body>
</html>
